//
//  QLViewController.m
//  Test
//
//  Created by Shrek on 15/5/12.
//  Copyright (c) 2015年 Personal. All rights reserved.
//

/** QLDEBUG Print */
#ifdef DEBUG
#define QLLog(FORMAT, ...) fprintf(stderr,"M:%s|L:%d :%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define QLLog(FORMAT, ...)
#endif

#import "QLViewController.h"
#import <pthread.h>

@interface QLViewController ()

@end

@implementation QLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadDefaultSetting];
}

#pragma mark - Load default UI and Data
- (void)loadDefaultSetting {
    QLLog(@"%@", [NSThread currentThread]);
    pthread_t threadId;
    /**
     *  创建一条线程,并且返回创建线程的状态
     *
     *  @param <#pthread_t *restrict#> 线程Id(out类型的参数,线程创建成功之后就会传回一条ID)
     *  @param <#const pthread_attr_t *restrict#> 线程的一些属性
     *  @param <#void *(*)(void *)#> 创建成功并启动之后的回调函数
     *  @param <#void *restrict#> 未知
     *
     *  @return 创建线程的状态
     */
    pthread_create(&threadId, NULL, start, NULL);
}

void *start(void *data) {
    QLLog(@"%@", [NSThread currentThread]); // 默认在子线程中执行
    // 在这里做耗时操作
    return NULL;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
